<?php
	$db               = new model_product;
	$pager            = new libraries_pager();
	$data             = array();
	$data['title']    = "Danh mục";
	$data['template'] = "product/list_product";
	$data['act']      = 0;
	$limit            = 20;
	$data['group']    = $db->list_group();
	$pager->set_link("index.php?mod=product&act=list");
	$total            = $db->total_pro();
	$start            = $pager->start();
	$pages            = $pager->page($total,$limit);
	$data['pagelist'] = $pager->listpage($pages,$start,$limit);
	$data['list']     = $db->list_product($start,$limit);
	if(isset($_GET['cid'])){
		$data['title']    = "Danh mục";
		$data['template'] = "product/list_product";
		$id = $_GET['cid'];
		$limit            = 20;
		$data['group']    = $db->list_group();
		$pager->set_link("index.php?mod=product&act=list&cid=$id");
		$total            = $db->total_pro_group($id);
		$start            = $pager->start();
		$pages            = $pager->page($total,$limit);
		$data['pagelist'] = $pager->listpage($pages,$start,$limit);
		$data['list']     = $db->list_group_product($start,$limit,$id);
		loadview("layout",$data);
	}else{
		loadview("layout",$data);
	}